import {createAction} from 'redux-actions';
import {
  POST_ORDER_SUBMIT,
  POST_PRICE_EXTRACT
} from './../constants/actionTypes'
import * as orderApi from './../apis/order'


export const orderSubmit = createAction(POST_ORDER_SUBMIT, async(params)=>{
  return await orderApi.postOrderSumbit(params)
    .then((data) =>{
      if (data){
        return data
      }
      throw 'orderSubmitError'
    })
}, (params)=>{
  return {
    ...params,
    sync: 'orderSubmit'
  }
})


export const priceExtract = createAction(POST_PRICE_EXTRACT, async(params)=>{
  return await orderApi.postPriceExtract(params)
    .then((data) =>{
      if (data){
        return data
      }
      throw 'priceExtractError'
    })
}, (params)=>{
  return {
    ...params,
    sync: 'priceExtract'
  }
})